﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using DiscoveryLogic.DataViz.NetworkDiagram.NetworkData;
using DiscoveryLogic.DataViz.NetworkDiagram.Rules;

namespace DiscoveryLogic.DataViz.NetworkDiagram.LinkerControls
{
    /// <summary>
    /// 
    /// </summary>
    public class GenericEntityLinker:IEntityLinker
    {
        #region fields

        private Dictionary<string, PropertyInfo> srcProps=new Dictionary<string, PropertyInfo>();
        private Dictionary<string, PropertyInfo> tgtProps=new Dictionary<string, PropertyInfo>();

        #endregion

        #region Implementation of IEntityLinker

        /// <summary>
        /// 
        /// </summary>
        public List<string> ArgNames
        {
            get
            {
                return new List<string>();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="srcEntityType"></param>
        /// <param name="tgtEntityType"></param>
        /// <param name="bindings"></param>
        public void InitBindings(Type srcEntityType, Type tgtEntityType, 
            Dictionary<string, ArgumentFieldBinding> bindings)
        {
            this.srcProps=new Dictionary<string, PropertyInfo>();
            PropertyInfo[] props1 = srcEntityType.GetProperties();
            foreach(PropertyInfo prop in props1)
                this.srcProps.Add(prop.Name,prop);
            PropertyInfo[] props2 = tgtEntityType.GetProperties();
            foreach(PropertyInfo prop in props2)
                this.tgtProps.Add(prop.Name,prop);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity1"></param>
        /// <param name="entity2"></param>
        /// <returns></returns>
        public double? CalculateDistance(BaseEntity entity1, BaseEntity entity2)
        {
            return 1.0;
        }

        #endregion
    }
}
